home *** CD-ROM | disk | FTP | other *** search
/ Aminet 22 / Aminet 22 (1997)(GTI - Schatztruhe)[!][Dec 1997].iso / Aminet / dev / misc / WHDLoaddev.lha / WHDLoad / Src / sources / keyboard.s < prev    next >
Text File  |  1997-09-02  |  2KB  |  60 lines

  1. ;*---------------------------------------------------------------------------
  2. ;  :Program.    keyboard.s
  3. ;  :Contents.    routine to setup an keyboard handler
  4. ;  :History.    30.08.97 extracted from some slave sources
  5. ;  :Requires.    _keydebug    byte variable containing rawkey code
  6. ;        _keyexit    byte variable containing rawkey code
  7. ;        _debug        function to quit with debug
  8. ;        _exit        function to quit
  9. ;  :Copyright.    Public Domain
  10. ;  :Language.    68000 Assembler
  11. ;  :Translator.    Barfly V1.131
  12. ;  :To Do.
  13. ;---------------------------------------------------------------------------*
  14.  
  15. ; IN:    -
  16. ; OUT:    d0-d1/a0-a1 destroyed
  17.  
  18. _SetupKeyboard    lea    (.int2),a0
  19.         move.l    a0,($68)            ;set interrupt vector
  20.         lea    (_ciaa),a1
  21.         move.b    #CIAICRF_SETCLR|CIAICRF_SP,(ciaicr,a1)    ;allow ints from keyboard
  22.         tst.b    (ciaicr,a1)            ;clear all intreq
  23.         and.b    #~(CIACRAF_SPMODE),(ciacra,a1)    ;input mode
  24.         move.w    #INTF_PORTS,(intreq+_custom)
  25.         move.w    #INTF_SETCLR|INTF_INTEN|INTF_PORTS,(intena+_custom)
  26.         rts
  27.  
  28. .int2        movem.l    d0-d1/a1,-(a7)
  29.         lea    (_ciaa),a1
  30.         btst    #CIAICRB_SP,(ciaicr,a1)        ;check int reason
  31.         beq    .int2_exit
  32.         move.b    (ciasdr,a1),d0            ;read code
  33.         clr.b    (ciasdr,a1)            ;output LOW (handshake)
  34.         or.b    #CIACRAF_SPMODE,(ciacra,a1)    ;to output
  35.         not.b    d0
  36.         ror.b    #1,d0
  37.  
  38.         cmp.b    (_keydebug),d0
  39.         bne    .int2_1
  40.         movem.l    (a7)+,d0-d1/a1
  41.         move.w    (a7),(6,a7)            ;sr
  42.         move.l    (2,a7),(a7)            ;pc
  43.         clr.w    (4,a7)                ;ext.l sr
  44.         bra    _debug
  45.  
  46. .int2_1        cmp.b    (_keyexit),d0
  47.         beq    _exit
  48.  
  49.         moveq    #3-1,d1                ;wait because handshake min 75 µs
  50. .int2_w1    move.b    (_custom+vhposr),d0
  51. .int2_w2    cmp.b    (_custom+vhposr),d0        ;one line is 63.5 µs
  52.         beq    .int2_w2
  53.         dbf    d1,.int2_w1            ;(min=127µs max=190.5µs)
  54.  
  55.         and.b    #~(CIACRAF_SPMODE),(ciacra,a1)    ;to input
  56. .int2_exit    move.w    #INTF_PORTS,(intreq+_custom)
  57.         movem.l    (a7)+,d0-d1/a1
  58.         rte
  59.  
  60.